#define _CRT_SECURE_NO_WARNING
#include<stdio.h>
#include <math.h>
#include <windows.h>
int main()
{
	int i = 0;
	for(i=0;i<=99999;i++)
	{
		int conut = 1;
		int tmp = i;
		int sun = 0;
		while(tmp/10)
		{
			conut++;
			tmp = tmp / 10;
		}
		tmp = i;
		while(tmp)
		{
			sun += pow(tmp % 10, conut);
			tmp = tmp / 10;
		}
		if (i == sun)
			printf("%d ", sun);
	}
	return 0;
}

